package springboot.kafka.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

/**
 * @author LiuWei
 * @description
 * @date 2019/9/25
 */
@Configuration
public class RestTemplateConfiguration {

    @Bean //必须new 一个RestTemplate并放入spring容器当中,否则启动时报错
    public RestTemplate restTemplate() throws Exception {
        HttpComponentsClientHttpRequestFactory factory = new
                HttpComponentsClientHttpRequestFactory();
        factory.setConnectionRequestTimeout(60 * 1000);
        factory.setConnectTimeout(60 * 3000);
        factory.setReadTimeout(60 * 3000);
        RestTemplate restTemplate = new RestTemplate(factory);
        return restTemplate;

    }
}
